package com.example.springioc.controller;

import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RestController
@RequestMapping("/log")
public class LogController {

//    private Logger logger = LoggerFactory.getLogger(LogController.class);
//
//    @PostConstruct
//    @RequestMapping("/printLog1")
//    public void printLog() {
//        logger.info("info日志");
//        logger.error("error日志");
//        logger.warn("warn日志");
//    }


    @PostConstruct
    @RequestMapping("/printLog2")
    // 在类上加上@Slf4j注解，系统会帮我们创建一个Logger对象，引用名为log
    public static void printLog1() {
        log.info("info日志");
        log.error("error日志");
        log.warn("warn日志");
    }

}
